'''
Created on 07.08.2011

@author: osman
'''

import opf
from pets_ontology import Pets, Pet

@Pets
class Snake(Pet):
    @opf.attribute
    def length(self, val): hasLength(self, val)

@Pets.atomic
def hasLength(snake: Snake, val: int) -> 'has length':
    return val > 0

with Pets:
    lola = Snake('Lola')
    lola.length = 20

print(Pets.graph)
print("lola length:", lola.length)

# Check predicate conditions work:

Pets.eraseGraph()

with Pets:
    lola = Snake('Lola')
    lola.length = -1

print(Pets.graph)
print("lola length:", lola.length)
